package com.zohnblog.dao;

import com.zohnblog.model.domain.WebStatistic;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

@Mapper
public interface WebStatisticMapper {
    @Insert("INSERT into t_web_statistic (requests, date) values (#{requests}, #{date})")
    public Integer addWebStatistic(WebStatistic webStatistic);

    @Select("SELECT * FROM t_web_statistic WHERE date = #{date}")
    public WebStatistic getWebStatisticByDate(String date);

    @Select("SELECT requests FROM t_web_statistic WHERE date = #{date}")
    public Integer getRequestsByDate(String date);

    @Update("UPDATE t_web_statistic SET requests = requests + 1 WHERE date = #{date}")
    public Integer addRequestsByDate(String date);
}
